<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>域名变更通知</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; background-color: #f4f4f9; }
        h1 { color: #333; text-align: center; }
        p { margin-top: 20px; font-size: 16px; color: #555; }
        ul { list-style-type: none; padding: 0; }
        li { background-color: #fff; border: 1px solid #ddd; margin-bottom: 10px; padding: 15px; border-radius: 5px; }
        .added { color: green; }
        .removed { color: red; }
        a { text-decoration: none; color: #007BFF; }
        a:hover { text-decoration: underline; }
        .domain-header { font-weight: bold; margin-bottom: 10px; cursor: pointer; }
        .subdomains { margin-left: 20px; display: none; }
        .subdomains.show { display: block; }
        .expand-indicator { font-size: 14px; color: #888; }
    </style>
</head>
<body>
    <h1>域名变更通知</h1>
    <p>{{ message }}</p>
    <ul>
        {% for domain, info in domains.items() %}
        <li>
            <div class="domain-header" onclick="toggleSubdomains(this)">
                {{ domain }} (新增: {{ info.count }})
                <span class="expand-indicator">点击展开</span>
            </div>
            <ul class="subdomains">
                {% for subdomain in info.subdomains %}
                <li>
                    <strong class="added"><a href='http://{{ subdomain }}' target='_blank'>{{ subdomain }}</a>
                </li>
                {% endfor %}
            </ul>
        </li>
        {% endfor %}
    </ul>

    <script>
        function toggleSubdomains(element) {
            const subdomains = element.nextElementSibling;
            const indicator = element.querySelector('.expand-indicator');
            if (subdomains.classList.contains('show')) {
                subdomains.classList.remove('show');
                indicator.textContent = '点击展开';
            } else {
                subdomains.classList.add('show');
                indicator.textContent = '点击收起';
            }
        }
    </script>
</body>
</html>